package com.zhongen.admin.api.feign;

import com.zhongen.admin.api.dto.UserDTO;
import com.zhongen.admin.api.dto.UserInfo;
import com.zhongen.admin.api.entity.SysUser;
import com.zhongen.common.core.constant.SecurityConstants;
import com.zhongen.common.core.constant.ServiceNameConstants;
import com.zhongen.common.core.util.R;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.*;

@FeignClient(contextId = "remoteUserService", value = ServiceNameConstants.UPMS_SERVICE)
public interface RemoteUserService {

	/**
	 * 通过用户名查询用户、角色信息
	 * @param user 用户查询对象
	 * @param from 调用标志
	 * @return R
	 */
	@GetMapping("/user/info/query")
	R<UserInfo> info(@SpringQueryMap UserDTO user, @RequestHeader(SecurityConstants.FROM) String from);

	/**
	 * 锁定用户
	 * @param username 用户名
	 * @param from 调用标识
	 */
	@PutMapping("/user/lock/{username}")
	R<Boolean> lockUser(@PathVariable("username") String username, @RequestHeader(SecurityConstants.FROM) String from);

	/**
	 * 小程序一键登录创建用户
	 * @param user 用户信息
	 * @param from 调用标志
	 * @return R
	 */
	@PostMapping("/user/wx")
	R<Boolean> createUser(UserDTO user, @RequestHeader(SecurityConstants.FROM) String from);

	@PostMapping("/user/innerAddUser")
	R innerAddUser(UserDTO user, @RequestHeader(SecurityConstants.FROM) String from);

	@PostMapping("/user/innerUpdateUser")
	Boolean innerUpdateUser(UserDTO user, @RequestHeader(SecurityConstants.FROM) String from);

	@PostMapping("/user/innerQueryUserByCondition/{condition}/{value}")
	SysUser innerQueryUserByCondition(@PathVariable("condition") String condition, @PathVariable("value") String value,
			@RequestHeader(SecurityConstants.FROM) String from);

	@PutMapping("/user/updateByUsernames")
	void updateByUsernames(UserDTO userDTO, @RequestHeader(SecurityConstants.FROM) String from);

}
